[models] Replace thirdparty JSONField with Django built-in JSONField #1111
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist
Reference to Existing Issue
Closes #1061.
Description of Changes
This PR replaces the third-party
jsonfieldpackage with Django's built-inJSONFieldacross all OpenWISP controller models to modernize the codebase and remove dependency on an unmaintained package.Changes Made:
Updated 6 model files to use
django.db.models.JSONFieldinstead of third-partyjsonfield.JSONField:openwisp_controller/config/base/base.pyopenwisp_controller/config/base/config.pyopenwisp_controller/config/base/device_group.pyopenwisp_controller/config/base/multitenancy.pyopenwisp_controller/config/base/template.pyopenwisp_controller/connection/base/models.pyCreated 2 migration files to safely alter field types:
openwisp_controller/config/migrations/0061_replace_jsonfield_with_django_builtin.pyopenwisp_controller/connection/migrations/0010_replace_jsonfield_with_django_builtin.pyRemoved jsonfield-specific parameters (
load_kwargs,dump_kwargs) that are not supported by Django's JSONFieldFixed code quality issues by removing unused imports and duplicate imports
Technical Details:
JSONFieldhandles JSON serialization internally without needing external parametersload_kwargs={"object_pairs_hook": collections.OrderedDict}is no longer needed as Python 3.7+ dicts maintain insertion orderdump_kwargs={"indent": 4}formatting should be handled at the serialization/display layer, not the model level